<template>
  <el-container>
    <el-header>
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: $store.state.authority===4?'/admin/library':'/library' }">论文库</el-breadcrumb-item>
        <el-breadcrumb-item ><el-link @click="handlePaperLink()">论文详情</el-link></el-breadcrumb-item>
        <el-breadcrumb-item >笔记查看</el-breadcrumb-item>
      </el-breadcrumb>
    </el-header>
    <el-main>
      <div v-if="editable">
        <note-editor :paper-id="paperId">
        </note-editor>
      </div>
      <div v-if="editable===false">
        <note-details :note-id="noteId">
        </note-details>
      </div>
      <div class="comment" v-if="noteId!==0">
        <comment :note-id="noteId"></comment>
      </div>
      <el-empty description="请先发布笔记" v-else></el-empty>
    </el-main>
  </el-container>
</template>

<script>
import NoteEditor from "./NoteEditor";
import NoteDetails from "./NoteDetails";
import Comment from "./Comment";
export default {
  name: "Note",
  inject:['reload'],
  components:{NoteEditor,NoteDetails,Comment},
  data(){
    return{
      paperId:0,
      noteId:0,
      editable:false
    }
  },
  methods:{
    //查看论文详情
    handlePaperLink() {
      let name
      if(this.$store.state.authority===4)
        name='AdminDetails'
      else
        name='Details'
      this.$router.push({
        name: name,
        params: {
          paperId:this.paperId,
        }
      }).then(()=>{
        this.reload()
      })
    }
  },
  created() {
    this.paperId=this.$route.params.paperId
    this.noteId=this.$route.params.noteId
    this.editable=this.$route.params.editable
  }
}
</script>

<style scoped>

</style>
